package com.linwen.excise.od.C;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

/**
 * @ClassName _测试人力执行计划
 * @Description TODO
 * @Author zero
 * @DATE 2024/4/5 1:09 AM
 * @Version 1.0
 */
public class _测试用例执行计划 {
    public static void main(String[] args) {
        int n = 5;
        int m = 4;
        int[] N = new int[]{1,1,2,3,5};
        int[][] M = new int[][]{{1,2,3},{1,4},{3,4,5},{2,3,4}};
        System.out.println(function(n,m,N,M));
    }

    private static List<Integer> function(int n, int m, int[] N, int[][] M) {
        List<Integer> result = new ArrayList<>();
        for (int i = 0; i < M.length; i++) {
            result.add(0);
            for (int i1 : M[i]) {
                result.set(i, result.get(i) + N[i1-1]);
            }
        }
        int[][] temp = new int[result.size()][2];
        for (int i = 0; i < result.size(); i++) {
            temp[i][0] = result.get(i);
            temp[i][1] = i;
        }
        Arrays.sort(temp, (o1, o2) -> {
            if(o1[0]!=o2[0]) {
                return o2[0]-o1[0];
            }
            return o1[1]-o2[1];
        });
        for (int i = 0; i < temp.length; i++) {
            System.out.print(temp[i][1]+1+"  ");
        }
        return result;
    }
}
